package cn.xingzhen.jfield.componet;

import javax.swing.*;
import java.awt.*;

/**
 * @author wenqiang
 * @date 2023/5/6
 * @comment ..
 */
public class XzComboBox<E> extends JComboBox<E> {

    public XzComboBox(E... es) {
        super();
        for(E e : es) {
            this.addItem(e);
        }
        setPreferredSize(new Dimension(XzUIConfigure.DEFAULT_WIDTH_COMBOBOX, XzUIConfigure.DEFAULT_COMPONENT_HEIGHT));
        initDefault();
    }

    public XzComboBox(int width) {
        super();
        setPreferredSize(new Dimension(width, XzUIConfigure.DEFAULT_COMPONENT_HEIGHT));
        initDefault();
    }

    private void initDefault() {
        if(XzUIConfigure.SHOW_BORDER) {
            setBorder(BorderFactory.createLineBorder(XzUIConfigure.BORDER_COLOR));
        }
    }

    public XzComboBox addItem(E... es) {
        for(E e : es) {
            super.addItem(e);
        }
        return this;
    }
}
